<div class="bjui-pageHeader">
    <form id="pagerForm" data-toggle="ajaxsearch" action="${request.getContextPath()}/DefectTrends/defectTrends" method="post">
        <div class="bjui-searchBar">
            <g:hiddenField name="SYS_QUERY_NAME" value="defectTrends" />
            <g:hiddenField name="EXPORT_CONTENT_NAME" value="Excel" />
            <label >产品编码：</label>&nbsp;
            <input type="text" name="partName" value="${partName}"/>

            <label >批号：</label>&nbsp;
            <input type="text" name="batchid" value="${batchid}"/>

            <label >不良类型：</label>&nbsp;
            <input type="text" name="defectcode" value="${defectcode}"/>


            <label >时间段：</label>&nbsp;
            <input type="text" name="startTime" value="${startTime}" data-pattern="yyyy-MM-dd"  data-toggle="datepicker" placeholder="FROM">
            <input type="text" name="endTime" value="${endTime}" data-pattern="yyyy-MM-dd" data-toggle="datepicker" placeholder="TO">&nbsp;&nbsp;
            <button type="submit" class="btn-default" data-icon="search">查询</button>&nbsp;
            <button type="button" class="btn-blue" onclick="javascript:bjuiExportExl('#pagerForm','${request.getContextPath()}/DefectTrends/exportExcel')" data-icon="file-excel-o" title="导出Excel">导出</button>&nbsp;
        </div>
    </form>
</div>

<div class="bjui-pageContent tableContent">
    <g:if test="${defectTrends.size() > 0}">
        <div id="defectTrends" style="width:100%;height:450px;margin: auto" ></div>
        <script  src="${request.getContextPath()}/js/echarts/echarts.js"></script>
        <script  src="${request.getContextPath()}/js/echarts/echarts-tool.js"></script>
        <script type="text/javascript">
            // 基于准备好的dom，初始化echarts实例
            var contextPath = "${request.getContextPath()}";
            eChartsTool.init(contextPath);
            var data=[];
            <g:each in="${defectTrends}" status="i" var="tableInstance">
            data.push('${tableInstance.DEFECT_CODE}');
            </g:each>

            // 指定图表的配置项和数据
            var option = {
                /*backgroundColor: 'rgba(0,0,0,0)', // 工具箱背景颜色*/
                // 图表标题
                toolbox: {

                    show: true,

                    feature: {

                        saveAsImage: {

                            show: true,

                            excludeComponents: ['toolbox'],

                            pixelRatio: 2

                        }
                    }

                },
                title: {

                },

                tooltip : {
                    trigger: ''
                },

                legend: {
                    data:['缺陷数量','累计比']

                },
                xAxis: {
                    data:data

                },
                yAxis : [
                    {
                        type : 'value',
                        name:'缺陷数量'
                    },
                    {
                        type : 'value',
                        name:'累计比',

                        axisLabel : {
                            formatter: '{value}%'
                        },
                        show:true
                    }
                ],
                series : [
                    {
                        name: '缺陷数量',
                        type: 'bar',
                        data:${listDefectCount}
                    },
                    {
                        name: '累计比',
                        type: 'line',
                        data:${list},
                        yAxisIndex: 1
                    }]
            };
            // 使用刚指定的配置项和数据显示图表。
            eChartsTool.setOption("roma", document.getElementById('defectTrends'), option);
        </script>
    </g:if>
    <div style="margin:15px auto; width:96%;">
        <div class="row" style="padding: 0px 0px;">
            <div class="col-md-12" >
                <g:if test="${defectTrends.size() > 0}">
                    <table data-toggle="tablefixed" data-width="100%" data-nowrap="true">
                        <thead>
                        <tr>

                            <g:each in="${tableHeadList}" status="i" var="headInstance">
                                <g:if test="${headInstance != 'RN'}">
                                    <th><g:message code="${headInstance}" default="${headInstance}"/></th>
                                </g:if>
                            </g:each>
                            <th>累计比(%)</th>
                        </tr>
                        </thead>
                        <tbody>
                        <g:each in="${defectTrends}" status="i" var="dataInstance">
                            <tr>

                                <g:each in="${tableHeadList}" status="j" var="headInstance">
                                    <g:if test="${headInstance != 'RN'}">
                                        <td>${dataInstance["${headInstance}"]}</td>
                                    </g:if>
                                </g:each>
                                <td>${list[i]}</td>
                            </tr>
                        </g:each>
                        <tr>
                            <td>TOTAL</td>
                            <td>${defectTrendsSumQty.SUM_DEFECT_COUNT[0]}</td>
                            <td>${defectTrendsSumQty.SUM_CHECK_RATIO[0]}</td>

                        </tr>
                        </tbody>
                    </table>
                </g:if>
                <g:else>
                    <g:render template="../template/emptyPanel"/>
                </g:else>
            </div>
        </div>
    </div>
</div>


